#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int getDecimalValue(ListNode* head)
    {
        int sum = 0;
        vector<int> v;
        ListNode* cur = head;
        while (cur != nullptr)
        {
            v.push_back(cur->val);
            cur = cur->next;
        }

        int i = 0;
        vector<int>::reverse_iterator rit = v.rbegin();
        while (rit != v.rend())
        {
            sum += pow(2, i) * (*rit);
            i++;
            rit++;
        }
        return sum;
    }
};